
#include <serpent.h>

/*
bool create_io(io o, str type);
bool start_io(io o);


bool register_revc_io(io o, void* (*callback)(void* attr));
bool unregister_recv_io(io o, void* (*callback)(void* attr));

bool register_send_io(io o, void* (*callback)(void* attr));
bool unregister_send_io(io o, void* (*callback)(void* attr));


bool stop_io(io o);
bool destroy_io(io o);
*/

io create_io(queue q, str name, str type) { // TODO: anchor to queue
	io o;
	if( NULL == ( o = (io)create_obj(OBJ_IO)) )
		return(NULL);

	// TODO: sanity check io type -> maybe on io_start ?
	if( !prop_add(o, "name", name) )
	{
		return(NULL);
	}

	if( !prop_add(o, "iotype", type) )
	{
		return(NULL);
	}

	if( !prop_add(o,"state","stopped") )
	{
		return(NULL);
	}

	return(o);
}

bool destroy_ios(queue q) {
	io o = q->io;
	if( o == NULL )
		return(false);

	props_destroy(o);
	s_free(o);
	return(true);
}
